<template>
  <page-header-wrapper>
    <!-- <application-search @search="handleSearch" @reset="handleReset"></application-search> -->
    <a-card :bordered="false">
      <s-table
        ref="table"
        size="default"
        :rowKey="(record, index) => index"
        :columns="columns"
        :data="loadData"
        :scroll="{ x: true }"
        :pagination="{ showTotal: (total) => `共 ${total} 条` }"
      >
        <div slot="tabAction"></div>
        <span slot="index" slot-scope="text, record, index">{{ index + 1 }}</span>
        <span slot="CityRfyDate" slot-scope="text">{{ text | moment }}</span>
        <div slot="action" slot-scope="text, record">
          <y-button type="link" @click="handleDetail(record.ID)">查看</y-button>
        </div>
      </s-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { STable, Ellipsis, buttonSelect, applicationSearch } from '@/components'
import { getESitesListInfobyRegionNo } from '@/api/common'
export default {
  name: 'cityComplexInquireList',
  components: {
    STable,
    Ellipsis,
    buttonSelect,
    applicationSearch,
  },
  computed: {
    textColor() {
      return function (text) {
        if (text === '') {
          text = '未审核'
        }
        const classMap = new Map([
          ['未审核', 'text-warning'],
          ['未审批', 'text-warning'],
          ['未上报', 'text-warning'],
          ['已上报', 'text-success'],
          ['不符合', 'text-error'],
          ['符合', 'text-success'],
          ['已接收', 'text-primary'],
          ['已退回', 'text-error'],
        ])
        return classMap.get(text)
      }
    },
  },
  data() {
    return {
      queryParam: {
        UserID: this.$store.getters.userid,
        Mode: 'all',
        strContent: {},
        sessionKey: 'FD167540D68E08FA155D0BFBC1238AF4',
        RegionNo: this.$store.getters.userInfo.DeptID,
      },
      queryParamFamily: {
        UserID: this.$store.getters.userid,
        Mode: 'ComplexQueryDetail',
        strContent: {},
      },
      columns: [
        {
          title: '序号',
          align: 'center',
          width: '80px',
          scopedSlots: { customRender: 'index' },
        },
        {
          title: '安置点编号',
          align: 'center',
          dataIndex: '安置点',
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: '项目',
        },
        {
          title: '区域',
          align: 'center',
          dataIndex: '分管区级',
        },
        {
          title: '小区名称',
          align: 'center',
          dataIndex: '小区名称',
        },
        {
          title: '幢号',
          align: 'center',
          dataIndex: '栋',
        },
        {
          title: '单元',
          align: 'center',
          dataIndex: '单元',
        },
        {
          title: '楼层',
          align: 'center',
          dataIndex: '楼层',
        },
        {
          title: '房号',
          align: 'center',
          dataIndex: '附号',
        },
        {
          title: '户型',
          align: 'center',
          dataIndex: '结构',
        },
        {
          title: '面积',
          align: 'center',
          dataIndex: '面积',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: '状态',
        },
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, this.queryParam)
        return getESitesListInfobyRegionNo(requestParameters).then((res) => res)
      },
      loadDataFamily: (parameter) => {
        const requestParameters = Object.assign({}, parameter, this.queryParamFamily)
        return getESitesListInfobyRegionNo(requestParameters).then((res) => res)
      },
    }
  },
  methods: {
    handleSearch(values) {
      this.queryParam.strContent = values
      this.queryParamFamily.strContent = values
      this.tableRefresh(true)
    },
    handleReset() {
      this.queryParam.strContent = {}
      this.queryParamFamily.strContent = {}
      this.tableRefresh(true)
    },
    tableRefresh(refresh = false) {
      this.$refs.table.refresh(refresh)
    },
    handleDetail(id) {
      localStorage.setItem('browserCacheDetail', JSON.stringify({ id: id }))
      this.$router.push({
        name: 'DistrictComplexQueryDetail',
        params: {
          id,
        },
      })
    },
  },
}
</script>
<style lang="less" scoped>
.table-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
/deep/ .ant-table td {
  white-space: nowrap;
}
</style>
